#pragma once

#include "Includes.h"

#include "Handle.h"
#include "BluetoothDevice.h"
#include "Thread.h"
#include "BluetoothConnection.h"
#include "IConnectionEventReceiver.h"

typedef IConnectionEventReceiver<BluetoothConnection> IBluetoothConnectionEventReceiver;


class BluetoothRadio : public Thread {
public:

	BTH_ADDR getMacAddress();

	tstring getName();

	void setCallback( IBluetoothConnectionEventReceiver* callback );

	std::vector<BluetoothDevice> queryDevices();

	// Throws SocketException
	BluetoothConnection connectTo(BluetoothDevice device);
	
	// Throws SocketException
	virtual void run() override;

	~BluetoothRadio();

	// throws SocketException
	static std::vector<BluetoothRadio> queryLocalBtRadios();

private:
	IBluetoothConnectionEventReceiver* mCallback;

	// BtRadio objects can only be retrieved via queryLocalBtRadios
	BluetoothRadio(Handle handle, BLUETOOTH_RADIO_INFO info) ;

	SOCKET mSocket;
	Handle mRadioHandle;

	BLUETOOTH_RADIO_INFO mRadioInfo;
};
